package com.gxa.controller;

import com.gxa.model.ResultData;
import com.gxa.pojo.Grade;
import com.gxa.pojo.Subjects;
import com.gxa.service.SubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author 周区区
 * @version 1.0
 * @date 2021/8/4 10:43
 */
@Controller
public class SubController {
    @Autowired
    private SubService subService;

    /**
     * 查询所有科目信息
     * @return
     */
    @GetMapping("/findAllSub")
    @ResponseBody
    public ResultData findAllSub(){
        return subService.findAllSub();
    }

    @GetMapping("/delSub")
    @ResponseBody
    public ResultData delSubject(@RequestParam("id") Integer subId){
        System.out.println("接收到的id："+subId);
        return subService.delSub(subId);
    }

    @PostMapping("/updSub")
    @ResponseBody
    public ResultData updSubject(@RequestBody Subjects subjects){
        return subService.updSub(subjects);
    }


    @PostMapping("/addSub")
    @ResponseBody
    public ResultData addSubject(@RequestBody Subjects subjects){
        return subService.addSub(subjects);
    }
}
